<template>
  <div ref="posA5">
    <div class="print-wrap-210 print-wrap-normal" style="width:210mm; height: auto;
  font-size: 12px;
  padding: 10px;
  border: 1px solid #a5a5a5;
  box-shadow: 2px 2px 2px #d3d3d3;
  word-break: break-all;">
      <div style="text-align:center; ">
        <h2 class="hotelname">
          {{seller ? seller.name : "酒店"}}{{entity?entity.posName : '超市'}}结账单
        </h2>
      </div>

      <p class="panelone panelone2" style="clear:both;">
        <span>单号:</span>
        <span style="width: 30mm; flex: 0 0 auto;">{{entity ? entity.closingNo: 'J20191024000001'}}</span>
        <span style="width: 30mm;">创建时间:</span>
        <span>{{entity ? entity.creatTime : (nowDate + ' ' + nowTime + ' ') }}</span>
        <span style="width: 35mm;">结账时间：</span>
        <span>{{ entity ? entity.closingTime : (nowDate + ' ' + nowTime + ' ') }}</span>
      </p>


      <p class="panelone panelone2" style="clear:both;">
        <span>打印时间:</span>
        <span style="width: 30mm; flex: 0 0 auto;">{{ nowDate + ' ' + nowTime + ' '}}</span>

        <span style="width: 35mm;">操作员:</span>
        <span>{{entity ? entity.operator : '管理员'}}</span>
      </p>

      <table style="width:100%;font-size:13px;margin-bottom: 3px; " class="dastable">

        <tr>
          <td>项目</td>
          <td>单价</td>
          <td>数量</td>
          <td>金额</td>
        </tr>

        <tr>
          <td colspan="4">
            <hr style="border:1px dashed #000; height:1px" />
          </td>
        </tr>

        <tr v-for="item in entity.goodsEntities" :key="item.id">

          <td>
            {{item.shopEntity.shopName}}
          </td>

          <td>
            {{item.shopEntity.salePrice.toFixed(2)}}
          </td>

          <td>
            {{item.number}}
          </td>

          <td>
            {{(item.number * item.shopEntity.salePrice).toFixed(2)}}
          </td>

        </tr>


        <tr class="lastrow">
          <td colspan="4"></td>
        </tr>

        <tr>
          <td colspan="4">
            <hr style="border:1px dashed #000; height:1px">
          </td>
        </tr>

        <tr>
          <td>项目合计:</td>

          <td>
            {{entity?entity.sum1:'700'}}
          </td>
          <td>
            {{entity?entity.sum2:'700'}}
          </td>
          <td>
            {{entity?entity.sum3:'700'}}
          </td>
        </tr>

        <tr>
          <td colspan="4">
            <hr style="border:1px dashed #000; height:1px">
          </td>
        </tr>

        <tr>
          <td colspan="4">
            消费合计：{{ entity? entity.xiaofeiCount : '0' }}
          </td>
        </tr>

        <tr>
          <td colspan="4">
            优惠金额：{{ entity? entity.youhuiCount : '0' }}
          </td>
        </tr>

        <tr>
          <td colspan="4">
            实际应收：{{ entity? entity.yingshouCount : '0' }}
          </td>
        </tr>

        <tr>
          <td colspan="4">
            <hr style="border:1px dashed #000; height:1px">
          </td>
        </tr>

        <tr>
          <td colspan="4">
            支付方式：{{entity? entity.payMoneyInfo : '--'}}
          </td>
        </tr>

      </table>

      <div v-html="note" class="mf15mmwithbigsize"></div>

      <div style="margin-top:5px;">
        <p class="panelone">
          <span>预定电话: </span>
          <span>{{seller?seller.tel:"模板"}}</span>
        </p>

        <p class="panelone">
          <span>酒店地址: </span>
          <span>{{seller?seller.address:"模板"}}</span>
        </p>
        
        <div style="margin-top: 8px;"></div>
        
        <p class="panelone">
           <span>宾客签字: </span>
           <span class="inputspan"></span>
         </p>
         
        <div style="margin-top: 8px;"></div>
        
      </div>
    </div>
  </div>
</template>
<script>
  import moment from 'moment';
  export default {
    props: {
      //备注
      note: {
      	type: String,
      	default: ''
      },
    },
    data() {
      return {
        nowDate: "", // 当前日期
        nowTime: "", // 当前时间
        nowWeek: "", // 当前星期
        today: moment().format('YYYY-MM-DD'),
        user: {},
        seller: {},
        entity: {}
      };
    },
    methods: {
      initData(data) {
        this.entity = data
        this.$forceUpdate();
      },
      getUser() {
        this.$http({
          url: this.$http.adornUrl(`/hotel/thotelprinttemplate/printInfo`),
          method: 'get',
        }).then(({
          data
        }) => {
          if (data.code === 0) {
            this.user = data.user;
            this.seller = data.seller;
          }
        })
      },
      currentTime() {
        setInterval(this.getDate, 500);
      },
      getDate: function() {
        var _this = this;
        let yy = new Date().getFullYear();
        let mm = new Date().getMonth() + 1;
        let dd = new Date().getDate();
        let week = new Date().getDay();
        let hh = new Date().getHours();
        let mf =
          new Date().getMinutes() < 10 ?
          "0" + new Date().getMinutes() :
          new Date().getMinutes();
        if (week == 1) {
          this.nowWeek = "星期一";
        } else if (week == 2) {
          this.nowWeek = "星期二";
        } else if (week == 3) {
          this.nowWeek = "星期三";
        } else if (week == 4) {
          this.nowWeek = "星期四";
        } else if (week == 5) {
          this.nowWeek = "星期五";
        } else if (week == 6) {
          this.nowWeek = "星期六";
        } else {
          this.nowWeek = "星期日";
        }
        _this.nowTime = hh + ":" + mf;
        _this.nowDate = yy + "/" + mm + "/" + dd;
      }
    },
    mounted() {
      this.currentTime();
      if (this.info) {
        this.currData = this.priceMap[moment(this.info.peopleEntity.arrivalsTime).format('YYYY-MM-DD')]
      }
      this.getUser();
    },
  };
</script>

<style>
  .panelone {
    display: flex;
  }

  .panelone span:nth-child(2n + 1) {
    width: 23mm;
    text-align: right;
  }
</style>
